#include <string.h>
#include <iostream>
using std::cout;
using std::endl;

class Computer
{
public:
    Computer(const char * brand,double price)
    : _brand(new char[strlen(brand) + 1]())
    , _price(price)
    {
        strcpy(_brand,brand);
    }

    void print(){
        cout << "brand:" << _brand << endl;
        cout << "price:" << _price << endl;
    }

    ~Computer(){
        cout << "~Computer()" << endl;
        /* print(); */
        /* cout << endl; */
        if(_brand){
            delete [] _brand;
            _brand = nullptr;
        }
    }
private:
    char * _brand;
    double _price;
};

Computer pc3("lenovo",7000);

void test0(){
    Computer pc("Apple",20000);
    Computer pc2("Xiaomi",10000);
    static Computer pc4("Huawei",18000);
    /* cout << &pc4 << endl; */
    /* cout << &pc3 << endl; */

    int * p = new int(10);
    delete p;
    p = nullptr;

    Computer * ptc = new Computer("Asus",6000);
    /* ptc->print(); */
    /* (*ptc).print(); */
    delete ptc;
    ptc = nullptr;

}


int main(void){
    test0();
    cout << "over" << endl;
    return 0;
}
